<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
  <style>
    #s1 {
      position: absolute;
      color: #FFFFFF;
      bottom: 0px;
      right: 0px;
    }
  </style>
</head>
<body>
<input type="text" placeholder="请输入1-100之间的整数">
<span id="s1"></span>
<input type="button" value="猜一猜" onclick="f()">
<h3>结果：<span id="s2"></span></h3>
</body>
<script>
  let num = parseInt(Math.random() * 100);
  let i = document.querySelector("input")   /*调第一个input*/
  let s1 = document.querySelector("#s1")
  s1.innerText = num
  let s2 = document.querySelector("#s2")
  let times = 0;
  function f() {
    times += 1;
    if (i.value > num) {
      s2.innerText = "猜大了！"
    } else if (i.value < num) {
      s2.innerText = "猜小了！";
    } else {
      s2.innerText = "恭喜你，第"+times+"次猜对了！"
    }
  }
</script>
</html>